﻿{template 'header'}
{if $reply['status']==0 || $reply['status']==""}
<div class="alert alert-warning" style="text-align:center;position: fixed;top:40%;z-index: 2; width:80%;margin:0 10%;">活动已禁用！</div>
<div class="weui_mask"></div>
{/if}


<div style="height:10px;"></div>

<div class="fee_feedback_wrapper">
<div class="divbaoming4">
<div class="dlist1">一次上传照片2-5张，第一张为封面图</div>
<div class="dlist2"></div>
<div class="dlist3" id="chooseImages"><img src="{MODULE_URL}/template/static/images/jia.gif" class="bmimg"></div>
</div>
	<div>
		<ul class="fd_list2">
		<li><div class="tlt">性别</div><input name="sex" type="radio" value="2" checked> 女　　<input name="sex" type="radio" value="1" style="margin-left:5%"> 男</li>			
			<li>
			<div class="tlt">本人姓名</div>
			<div class="cont">
				<input name="name"  type="text" placeholder="请输入姓名或昵称" class="tx"></div>
			</li>
			<li>
			<div class="tlt">手机号码</div>
			<div class="cont">
				<input name="mobile" type="tel" placeholder="请输入本人手机号码" class="tx"></div>
			</li>
			<li>
			<div class="tlt">自我介绍</div>
			<div class="cont">
				<textarea name="introduction" class="ta" cols="" placeholder="简单介绍，请勿用表情"></textarea></div>
			</li>
			</ul>
		<div class="btn_area">
<div class="baomingtxt"><font color="#a0a0a0">请如实填写报名信息，手机号码是唯一获奖凭证</font></div>
<div class="baomingtxt"><font color="#a0a0a0"></font></div>
<div class="btn_bg_green">提交报名</div>
<div class="baomingtxt"><font color="#a0a0a0"></font></div>
		</div>

	</div>
</div>
<div class="follow" id="follow" style="display:none">
<div class="weui_mask"></div>
<div id="guanzhubox" >
	<div class="box1" onclick="hidemod('follow');">
	<span class="span1">未关注</span> 
	<span class="span2" >关闭</span></div>
	<div class="divtxt">
	<p>长按下方二维码，长按，识别二维码</p>
	<p><img src="{php echo $_W['account']['qrcode'];}" width="80%"></p>
	{$reply['followguide']}</div>
</div>
</div>
<script>
 $(document).ready(function(){	
     var images = {
       localId: [],
       serverId: []
     };
	 
    $("#chooseImages").click(function(){
       wx.chooseImage({
          success: function (res) {
			images.localId = res.localIds;
			if(images.localId.length < 2 || images.localId.length > 5){
			   images.localId = [];
			   dialog2("请上传2-5张图片");return false;//2-5张照片
			}
			$("#chooseImages").html(""); 
			for(var i=0;i < images.localId.length; i++){
				$("#chooseImages").append("<img src='"+images.localId[i]+"' class='bmimg' />");
			}
          }
       });
	});
	
	$(".btn_bg_green").click(function(){
		var name=$("input[name='name']").val();
		var sex=$("input[name='sex']:checked").val();
		var mobile=$("input[name='mobile']").val();
		var introduction=$("textarea[name='introduction']").val();
		{if $nofollow==1}
		$("#follow").show();return false;
		{/if}
		if(name==''){dialog2("请输入姓名");return false;}
		if(mobile==''){dialog2("请输入手机号");return false;}
		if(!(/^1[3|4|5|6|7|8|9][0-9]\d{4,8}$/.test(mobile))){dialog2("请输入正确的手机号码！");return false; } 
		if(introduction==''){dialog2("请输入个人简介");return false;}
		
		$(this).unbind();
		
        var i = 0, length = images.localId.length;
        images.serverId = [];
        function upload() {
          wx.uploadImage({
             localId: images.localId[i],
			 isShowProgressTips:2,
             success: function (res) {
               i++; 
               images.serverId.push(res.serverId);
               if (i < length) {
                  upload();
               } else {
			       loadingToast("正在提交...");
				      	$.ajax({
							type: "POST",
							url: "{php echo $this->createMobileUrl('join', array('rid' => $reply['rid']))}",
							data: {name:name,sex:sex,mobile:mobile,introduction:introduction,picturearr:images.serverId	},
							dataType: "json",
							success: function(str) {
								hidemod("loadingToast");
								if(str!=null && str!=''){
									if(str.status == 1){
										location.href="{php echo $this->createMobileUrl('view', array('rid' => $reply['rid']))}&id="+str.id;
									}else if(str.status == 500){
										$("#follow").show();
									}else{
										dialog2(str.msg);
									}
								}
							},
							error: function(err) {
								dialog2("发生错误，请刷新后重试！");
							}
						});
			   }
             },
             fail: function (res) {
				dialog2("发现错误，请重试");return false;
             }
          });
        }
       upload();
	});
	{if $nofollow==1}
	     setTimeout($("#follow").show(),30000);//延时3秒 
	{/if}
 });

</script>

{template 'footer'}